// pages/logistics/index.js
const {
  get
} = getApp();
Page({
  data: {
    data: {
      name: "",
      image: "",
      order_sn: "",
      ship_addr: "",
      ship_no: "",
      exp_name: "",
      courier: "",
      status:0
    },
    orderType: {
      1: "待付款",
      2: "已支付",
      3: "已发货",
      4: "已收货",
      5: "已完成",
      6: "取消订单",
      7: "交易成功售后中",
      8: "交易成功部分售后中"
    },
    steps: [],
  },
  //初始化加载
  onLoad: function (e) {
    this.getList(e.sn);
  },
  // 获取数据
  getList(e) {
    get("/member/logistics", {
      order_detail_sn: e
    }).then(res => {
      if (res.result == 1) {
        this.setData({
          "steps": res.data.steps,
          "data.name": res.data.name,
          "data.image": res.data.image,
          "data.order_sn": res.data.order_sn,
          "data.ship_addr": res.data.ship_addr,
          "data.ship_no": res.data.ship_no,
          "data.exp_name": res.data.exp_name,
          "data.courier": res.data.courier,
          "data.status":res.data.status
        })
      }
    })
  },
  // 复制
  copyOrderNum(e) {
    wx.setClipboardData({
      data: e.currentTarget.dataset.logistics,
      success() {
        wx.showToast({
          title: '复制成功',
          icon: 'success',
          duration: 2000
        })
      }
    })
  },
  onShow: function () {
    // 控制分享按钮
    wx.showShareMenu({
      withShareTicket: true,
      menus: ['shareAppMessage', 'shareTimeline'],
      success(res) {
        console.log('showShareMenu', res);
      }
    });
  }
})